<div class="span3">
	<div>
		<?php echo $this->Html->link(__('Compose'), array('action' => 'add'),array('class' => 'btn btn-primary btn-add-article')); ?>
	</div>
	<?php echo $this->element('tabs_vertical',compact('tabActive')); ?>
</div>
<div class="span9">
	<?php if($this->params['paging']['Article']['count']): ?>
		<div class="counter"><h4>
		<?php echo $this->Paginator->counter(array('format' => __('Showing %start% - %end% of %count% results'))); ?>
		</h4></div>
		<?php $article_status = Configure::read('article_status'); ?>
		<table class="table table-bordered table-striped">
			<thead>
			<tr>
				<th>#</th>
				<th><?php echo $this->Paginator->sort('title');?></th>
				<th><?php echo $this->Paginator->sort('link');?></th>
				<th><?php echo $this->Paginator->sort('category_id');?></th>
				<th><?php echo $this->Paginator->sort('status');?></th>
				<th></th>
			</tr>
			</thead>
			<tbody>
			<?php
			$i = 0;
			foreach ($articles as $article):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
			switch($article['Article']['status']){
				case ARTICLE_STATUS_ACCEPTED:
					$colorClass = ' class="text-blue"';
					break;
				case ARTICLE_STATUS_REJECTED:
					$colorClass = ' class="text-yellow"';
					break;
				case ARTICLE_STATUS_BLOCKED:
					$colorClass = ' class="text-red"';
					break;
				default:
					$colorClass = null;
			}
			?>
			<tr <?php echo $class;?>>
				<td><?php echo $i; ?></td>
				<td <?php echo $colorClass;?>><?php echo $article['Article']['title']; ?></td>
				<td><?php echo $article['Article']['link']; ?></td>
				<td><?php echo $article['Category']['title']; ?></td>
				<td><?php echo __($article_status[$article['Article']['status']]); ?></td>
				<td class="actions">
				<?php echo $this->Html->link(__('View'), array('action' => 'view', $article['Article']['id']), array('class'=> 'btn')); ?>
				
				<?php if(in_array($article['Article']['status'], array(ARTICLE_STATUS_REJECTED, ARTICLE_STATUS_DRAFT))){
				echo $this->Html->link(__('Edit'), array('action' => 'edit', $article['Article']['id']), array('class'=> 'btn'));
				}?>
				
				<?php if(!in_array($article['Article']['status'] ,array(ARTICLE_STATUS_ACCEPTED, ARTICLE_STATUS_BLOCKED))){
					echo $this->Html->link(__('Delete'), array('action' => 'delete', $article['Article']['id']), array('class'=> 'btn'), sprintf(__('Are you sure you want to delete this article ?'))); 
				}?>
				</td>
			</tr>
			<?php endforeach; ?>
			</tbody>
		</table>
		<div class="paging text-center">
		<?php echo $this->Paginator->prev('<< ' . __('previous'), array(), null, array('class'=>'disabled'));?>
			|
			<?php echo $this->Paginator->numbers();?>
			|
			<?php echo $this->Paginator->next(__('next') . ' >>', array(), null, array('class' => 'disabled'));?>
		</div>
	<?php else: ?>
	<div class="alert alert-info"><?php echo __('Not found article.')?></div>
	<?php endif ?>
</div>
